﻿#include "GUITimeHistoryACCELDialog.h"
#include "ui_GUITimeHistoryACCELDialog.h"

#include <QMessageBox>

namespace GUI
{
    GUITimeHistoryACCELDialog::GUITimeHistoryACCELDialog(Core::FITKActionOperator* oper,QWidget* parent)
        : Core::FITKDialog(parent), _oper(oper)
        , _ui(new Ui::GUITimeHistoryACCELDialog)
    {
        _ui->setupUi(this);
        
        init();
    }

    GUITimeHistoryACCELDialog::~GUITimeHistoryACCELDialog()
    {
        if (_ui)
            delete _ui;
    }

    void GUITimeHistoryACCELDialog::init()
    {
        _ui->tabWidget->setTabText(0, "Time Accel");
        _ui->tabWidget->setTabText(1, "Accel Table");

        _ui->tableWidget->setColumnCount(2);

        // 设置表头内容
        QStringList headers{};
        headers << "ID" << "Name" << "Frequency" ;
        _ui->tableWidget->setHorizontalHeaderLabels(headers);
        _ui->tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers); // 设置表格不可编辑
        
        this->initTableWidget();
    }

    void GUITimeHistoryACCELDialog::initTableWidget()
    {
        // 自适应列宽（根据内容调整，避免文本截断）
        _ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
    }

    bool GUITimeHistoryACCELDialog::checkData()
    {
        // 
        return true;
    }

    void GUITimeHistoryACCELDialog::on_pushButton_OK_clicked()
    {
        // 先检查数据合法性，不合法则直接返回
        if (!checkData()) return;
        accept();
    }

    void GUITimeHistoryACCELDialog::on_pushButton_Cancle_clicked()
    {
        reject();
    }

    void GUITimeHistoryACCELDialog::on_pushButton_Add_clicked()
    {
        
    }

    void GUITimeHistoryACCELDialog::on_pushButton_Remove_clicked()
    {

    }
} // namespace GUI
